package 单例模式;

/**
 * @author zzs
 * @ClassName Single.java
 * @Description 普通单例模式，每次获取对象都要同步，应该获取对象完就不应该再同步了
 * @createTime 2022年05月14日 20:08:00
 */
public class Single {
    private static Single single;

    public int a;

    private Single() {
        System.out.println("初始化");
    }

    public synchronized static Single getSingle() {
        if (single == null) {
            single = new Single();
        }
        return single;
    }
}
